<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{$category_array->itemCategoryName}-->信息表</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub"><!--{$category_array->itemCategoryName}-->信息表</span>
    </div>

    <div class="comm_content">


            <!--{if $category_array->itemCategoryID != 13}-->
            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td height="27px">
                                    <span><!--{$category_array->itemCategoryName}-->编号：<input type="text" name="itemID" id="itemID"></span>
                                    <span><!--{$category_array->itemCategoryName}-->名称：<input type="text" name="itemName" id="itemName"></span>
                                    <span><input type="button" value="查询" class="btn" onclick="item.search();" /></span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <!--{/if}-->

            <table id="flex" style="display:none"></table>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/item/item.ajax?operFlg=1&item=<!--{$item_category_id}-->",
        dataType: "json",
        colModel : [
            {display: "操作", width : 200, align: "center"},
            {display: "编号", name : "itemID", width : 100, sortable : true},
        <!--{if $category_array->itemCategoryID == 13}-->
        {display: "内容", width : 260},
        <!--{else}-->
        {display: "类型", width : 260},
        <!--{/if}-->
            {display: "状态", width : 100}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "item.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "item.delete"}
        ],
        sortname: "itemID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });
	
    var item = {
    	
    	itemCategoryID: '<!--{$item_category_id}-->',
    	
    	itemCategoryName: '<!--{$category_array->itemCategoryName}-->',
    	
    	delete_str: "",
    	
    	//查询
    	search: function () {
    		var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
    	},
    	
    	//添加
    	add: function (category_id) {
    		E.open("/quanliadmin/app/item/item.pscript?operFlg=3&category_id=" + this.itemCategoryID);
    	},
    	
		//编辑
    	edit: function(item,itemID) {
            E.open("/quanliadmin/app/item/item.pscript?operFlg=2&item="+item+"&itemID="+itemID);
        },
        
    	
    	//重新加载页面内容
    	load: function() {
            $("#flex").flexReload();
        },
        
        delete: function() {
            this.delete_str = "";
            $.each($("#flex").find("tr"), function(k, v) {
                if ($(v).hasClass("trSelected")) {
                    item.delete_str += "_" + $(v).attr("id").replace("row", "");
                }
            });

            if (this.delete_str == "")
                E.alert("请选择删除"+this.itemCategoryName);
            else
                E.confirm("您确认要删除选中的"+this.itemCategoryName+"吗？", "item.deleteConfirm");
        },
        
        deleteConfirm: function() {
            this.delete_str = this.delete_str.substr(1);
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/item/item.ajax?operFlg=3&delete_str=" + item.delete_str,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "item.load");
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        }
		
    };
</script>

</body>

</html>